<?php
require '../database/products.php';
$pro=new products();
$record=$pro->number_Record();
if(!isset($_GET['trang']))$_GET['trang']=1;
$vitri=($_GET['trang']-1)*10;
$data=$pro->page($vitri);
?>
<style>
    #showtable{
        height: 700px;    
    }
    #page{
        border-bottom: 1px solid #F30;
        height: 59px;
    }
</style>
 <script type="text/javascript">
        $(document).ready(function(){
            $("a.del").click(function(){
               if(confirm("Bạn có muốn xóa không ?")){
                  $id=$(this).attr("name"); 
                  $(this).parent().parent().fadeOut("slow");                 
                  $.ajax({
                      "url": "modules/products/deleteajax.php",                     "type":"post",
                      "data":"uid="+$id,
                      "async":"false",
                      success: function (data) {                     
                    }
                  });
               } 
               return false;
              
            });
        });
        </script>
<div id="showtable">
    <table border="1px">
        <tr>
            <td>Id</td>
            <td>Ten</td>
            <td>Gia</td>
            <td>Thong tin</td>
            <td>Dac tinh</td>
            <td>Hinh anh</td>
            <td>So luong</td>
            <td>Ngay nhap</td>
            <td>Chung loai</td>
        </tr>
        <?php foreach ($data as $value) {?>
        <tr>
            <td><?php echo $value['pro_id'];?></td>
            <td><?php echo $value['pro_name'];?></td>
            <td><?php echo $value['pro_price'];?></td>
            <td><?php echo $value['pro_info'];?></td>
            <td><?php echo $value['pro_full'];?></td>
            <td><?php echo $value['pro_image'];?></td>
            <td><?php echo $value['pro_number'];?></td>
            <td><?php echo $value['pro_inport'];?></td>
            <td><?php echo $value['pro_cateId'];?></td>
              <td> 
            <a href="#">
                <img src="images/detail.png" width="30" height="30" title="Chi tiet"></a>
            <a href="javascript:void(0)" class="del" name="<?php echo $value['pro_id'];?>">
                <img src="images/delete.png" width="30" height="30"title="Xoa"></a>
            <a href='<?php echo baseurl."admin/index.php?page=products&act=edit&id=".$value['pro_id'];?>'>
                <img src="images/update.png"width="30" height="30" title="Cap nhat"></a>
        </td>
        </tr>
        <?php }?>
    </table>
</div>
<div id="page">
    <?php $tongsotrang= ceil($record/10);
    for($i=1;$i<=$tongsotrang;$i++)
        echo "<a href='index.php?page=products&act=list&trang=$i'>$i</a>";
    ?>
</div>
